package org.activiti.solon.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.activiti.solon.entity.*;
import org.activiti.solon.service.FlowRunService;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.annotation.Post;

import java.util.List;

/**
 * 工作流运行
 */
@Slf4j
@Controller
@Mapping("/flow/run/")
public class FlowRunController {
    @Inject
    private FlowRunService flowRunService;

    /**
     * 发起工作流
     */
    @Post
    @Mapping("start")
    public List<AuditData> startTask(AuditTask task) {
        return flowRunService.startTask(task);
    }

    /**
     * 查看待办分页
     */
    @Post
    @Mapping("todo")
    public IPage<ActExtAuditVO> todoPage(PageExt<ActExtAuditVO> queryInfo) {
        return flowRunService.selectTodoPage(queryInfo);
    }

    /**
     * 工作流前进后退
     */
    @Post
    @Mapping("skip")
    public List<AuditData> skipTask(AuditTask task) {
        return flowRunService.skipTask(task);
    }

    @Post
    @Mapping("opinion")
    public List<ActExtFlowLogVO> opinion(ActExtAuditVO queryInfo) {
        return flowRunService.selectOpinionList(queryInfo);
    }
}
